<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport"
	content="width=device-width initial-scale=1.0  maximum-scale=1.0">
	<jsp:include page="/static/member/themes/default/header.jsp" />
<link href="${ctxStatic}/jquery-mobile/css/jquery.mobile-1.3.1.min.css"
	type="text/css" rel="stylesheet" />
<title>修改密码</title>

</head>
<body>
	<script type="text/javascript">
	

	$(document).ready(function() {
		$("#errorMessage").hide()
	});
		function checkForm() {

			var oldpwd = $.trim($('#oldpwd').val());
			var password = $.trim($('#password').val());
			var pwd = $.trim($('#pwd').val());
			var path = /^[0-9a-zA-Z]{6,50}$/;
			var isRandom = $('#isRandom').val();

			if (isRandom == "true") {
				if (password == null || password == '') {
					$("#errorMessage").html("请输入新密码");
					$("#errorMessage").show()
					return false;
				}
				else{
					$("#errorMessage").hide()
				}

				if (pwd == null || pwd == '') {
					$("#errorMessage").html("请输入确认密码");
					$("#errorMessage").show()
					return false;
				}
				else{
					$("#errorMessage").hide()
				}

				if (!path.test(password)) {
					$("#errorMessage").html("新密码至少6位");
					$("#errorMessage").show()
					return false;
				}
				else{
					$("#errorMessage").hide()
				}
				if (!path.test(pwd)) {
					$("#errorMessage").html("确认密码至少6位");
					$("#errorMessage").show()
					return false;
				}
				else{
					$("#errorMessage").hide()
				}

				if (password != pwd) {
					$("#errorMessage").html("两次输入密码不一致");
					$("#errorMessage").show()
					return false;
				}
				else{
					$("#errorMessage").hide()
				}

				return true;
			}

			if (isRandom == "false") {

				if (oldpwd == null || oldpwd == '') {
					$("#errorMessage").html("请输入原密码.");
					$("#errorMessage").show()
					return false;
				}
				else{
					$("#errorMessage").hide()
				}
				if (password == null || password == '') {
					$("#errorMessage").html("请输入新密码.");
					$("#errorMessage").show()
					return false;
				}
				else{
					$("#errorMessage").hide()
				}

				if (pwd == null || pwd == '') {
					$("#errorMessage").html("请输入确认密码.");
					$("#errorMessage").show()
					return false;
				}
				else{
					$("#errorMessage").hide()
				}

				if (!path.test(password)) {
					$("#errorMessage").html("新密码至少6位");
					$("#errorMessage").show()
					return false;
				}
				else{
					$("#errorMessage").hide()
				}
				if (!path.test(pwd)) {
					$("#errorMessage").html("确认密码至少6位");
					$("#errorMessage").show()
					return false;
				}
				else{
					$("#errorMessage").hide()
				}

				if (password != pwd) {
					$("#errorMessage").html("两次输入密码不一致");
					$("#errorMessage").show()
					
					return false;
				}
				else{
					$("#errorMessage").hide()
				}

				return true;
			}

			return false;

		}
	</script>
	<div class="main">
		<div>
			<div>
				<div class="ztContent">
					<div data-role="header" align="center" style="margin: 10px;">

					</div>
					
					<tags:message content="${message}"></tags:message>
						<div align="center">
					<form id="inputForm" action="${ctx}/member/updatePwd" method="post"
						onsubmit=" return checkForm();">
						<input type="hidden" name="uid" value="${uid }" /> <input
							type="hidden" name="topage" value="${topage }" /> <input
							type="hidden" name="wechatId" value="${wechatId }" /> <input
							type="hidden" name="style" value="${style}" /> <input
							type="hidden" id="isRandom" value="${ isRandomPassword  }">
					

							<c:if test="${ isRandomPassword == false  }">
								<div class="control-group">
									<div class="controls">
										原&nbsp;密&nbsp;&nbsp;码:&nbsp;&nbsp;<input name="oldpwd" id="oldpwd"
											type="password" maxlength="15" class="required input-medium input-medium"  style="height:26px;"/>
									</div>
								</div>
							</c:if>
							<div class="control-group">
								<div class="controls">
									新&nbsp;密&nbsp;&nbsp;码:&nbsp;&nbsp;<input name="password" id="password"
										type="password" maxlength="15" class="required input-medium input-medium" style="height:26px;"/>

								</div>
							</div>

							<div class="control-group">
								<div class="controls">
									确认密码:&nbsp;&nbsp;<input name="pwd" id="pwd" type="password"
										maxlength="15" class="required input-medium input-medium" style="height:26px;"/>
								</div>
							</div>
							<span> <font color="red">${errorMessage }</font></span>
							<div  align="center" class="alert" id="errorMessage" style="color:red;"  >
									
							</div>
							<div align="center">
								<input id="btnSubmit" class="btn btn-danger" type="submit"
									value="修改密码" />
							</div>
							


						
					</form>
</div>
				</div>
			</div>
		</div>
	</div>
	<c:if test="${uid ne '34' }">
		<jsp:include page="/static/member/themes/default/footer.jsp">
			<jsp:param value="${id }" name="uid" />
		</jsp:include>
	</c:if>
</body>



</html>